<template>
  <div>
    <div class="box" v-if="orderList.length !== 0">
      <div class="container" v-for="(item, index) in orderList" :key="index">
        <div class="container-herder">
          <span>{{item.createTime}}</span>
          <span>lin_xi</span>
          <span>{{item.orderNo}}</span>
          <span>{{item.paymentTypeDesc}}</span>
          <span>应付金额:{{item.payment}}元</span>
          <span @click="goPay(item.orderNo)">立即支付</span>
        </div>
        <div v-for="(v, i) in item.orderItemVoList" :key="i" class="container-content">
          <img :src="v.productImage" alt />
          <span>{{v.productName}}</span>
          <span>{{v.currentUnitPrice}}元 X {{v.quantity}}</span>
        </div>
      </div>
    </div>
    <div v-if="orderList.length === 0">暂无订单</div>
  </div>
</template>
<script>
export default {
  name: "order-list",
  data() {
    return {
      orderList: [],
    };
  },
  created() {
    this.axios.get("/user");
    this.axios.get("/orders").then((data) => {
      this.orderList = data.list;
      window.console.log(this.orderList);
    });
  },
  methods: {
    goPay(orderNo) {
      this.$router.push("/order/pay/" + orderNo);
    },
  },
};
</script>

<style lang="scss" scoped>
.box {
  width: 100%;
  background: #f5f5f5;
  border-top: solid 1px #f5f5f5;
  overflow: hidden;
  .container {
    width: 1224px;
    background-color: #fff;
    margin: 30px auto;
    border: solid 1px #ff6700;
    .container-herder {
      height: 74px;
      background-color: #fffaf7;
      color: #666666;
      font-size: 16px;
      line-height: 74px;
      span {
        margin: 20px;
      }
      :last-child {
        color: #ff6700;
        cursor: pointer;
      }
    }
    .container-content {
      img {
        width: 100px;
        vertical-align: middle;
      }
      span {
        margin: 20px;
      }
    }
  }
}
</style>